<?php
/**发放微店现金红包页面（直接加到余额）*/
$memberId = $_POST['memberId'];
$typeCode = $_POST['typeCode'] ? $_POST['typeCode'] : 'PIN_TUAN';
$price = $_POST['price']>0 ? $_POST['price'] : 0;
$orderId = $_POST['orderId']>0 ? $_POST['orderId'] : 0;
$desc = $_POST['desc'] ? $_POST['desc'] : "";
$mysign = $_POST['mysign'];
require_once ("config.php");

$cod_verify = new CodVerify($cod_config['key']);
$verify_result = $cod_verify->md5Verify($memberId, $mysign);
if ($verify_result) {
    include_once ($config["webroot"] . "/module/micro_shop/includes/plugin_micro_shop_class.php");
    $microShop = new MicroShop();
    $res = $microShop->giveOutBonusOfSelfCost($memberId,$price,$typeCode,$orderId,$desc);
    if ($res) {
        echo "success"; // 请不要修改或删除
    } else {
        //生成失败
        echo "fail";
    }
} else {
    
    // //验证失败
    echo "signError";
    
    // 调试用，写文本函数记录程序运行情况是否正常
    // logResult("这里写入想要调试的代码变量值，或其他运行的结果记录");
}

class CodVerify
{

    var $signKey;

    function __construct($signKey)
    {
        $this->signKey = $signKey;
    }

    function md5Verify($prestr, $sign)
    {
        $prestr = $prestr . $this->signKey;
        $mysgin = md5($prestr);
        
        if ($mysgin == $sign) {
            return true;
        } else {
            return false;
        }
    }
}




